<template>
  <LayTimeSelect v-model="current" class="time_select"/>
</template>

<script lang="ts" setup>
import { LayTimeSelect } from '@layui/layui-vue';
import { computed } from 'vue';

const modelValue = defineModel();

const current = computed({
  get: () => {
    if (modelValue.value === undefined) return undefined;
    const str = ('' + modelValue.value + '').padStart(6, '0');
    return `${str[0]}${str[1]}:${str[2]}${str[3]}:${str[4]}${str[5]}`;
  },
  set: (str?: string) => {
    if (!str) {
      modelValue.value = undefined;
      return;
    }
    const n = str.split(':').join('');
    modelValue.value = parseInt(n);
  },
});
</script>

<style scoped></style>
